package com.hk.commons;

import com.hk.model.vo.Result;
import com.hk.model.vo.ResultVO;
import com.hk.model.vo.UploadImage;
import com.hk.model.vo.UploadImageVO;
import com.hk.utils.ResultCodeEnum;

import java.util.List;

/**
 * @Author: aerfazhe
 * @Date: 2021/7/9 16:14
 * @Statement: 公共返回处理方法
 */
public class CommonResult {

    /**
     * Layui数据表格格式查询获取的值为空时
     * @param count
     * @param list
     * @return
     */
    public static ResultVO nullResultVO(Integer count, List list) {
        ResultVO resultVO = new ResultVO<>(ResultCodeEnum.NULL.getCode(), ResultCodeEnum.NULL.getMessage(),count,list);
        return resultVO;
    }

    /**
     * Layui数据表格格式成功时
     * @param count
     * @param list
     * @return
     */
    public static ResultVO successResultVO(Integer count,List list) {
        ResultVO resultVO = new ResultVO<>(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMessage(),count,list);
        return resultVO;
    }

    /**
     * 查询获取的值为空时
     * @param o
     * @return
     */
    public static Result nullResult(Object o) {
        Result result = new Result(ResultCodeEnum.NULL.getCode(), ResultCodeEnum.NULL.getMessage(),o);
        return result;
    }

    /**
     * 成功时
     * @param o
     * @return
     */
    public static Result successResult(Object o) {
        Result result = new Result(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMessage(),o);
        return result;
    }

    /**
     * 失败时
     * @param o
     * @return
     */
    public static Result errorResult(Object o) {
        Result result = new Result(ResultCodeEnum.ERROR.getCode(), ResultCodeEnum.ERROR.getMessage(),o);
        return result;
    }

    /**
     *  未登录
     * @param o
     * @return
     */
    public static Result acResult(Object o) {
        Result result = new Result(ResultCodeEnum.AC.getCode(), ResultCodeEnum.AC.getMessage(),o);
        return result;
    }

    /**
     * 上传文件格式成功时
     * @param o
     * @return
     */
    public static UploadImageVO successUploadImgVO(UploadImage o) {
        UploadImageVO uploadImageVO = new UploadImageVO(ResultCodeEnum.IMGSUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMessage(),o);
        return uploadImageVO;
    }

    /**
     * 上传文件格式失败时
     * @param o
     * @return
     */
    public static UploadImageVO errorUploadImgVO(UploadImage o) {
        UploadImageVO uploadImageVO = new UploadImageVO(ResultCodeEnum.ERROR.getCode(), ResultCodeEnum.ERROR.getMessage(),o);
        return uploadImageVO;
    }







}
